package com.calsoft.Hops_Mobile_Tablet.util;
/*
 * User: Minh Diep
 * Date: 7/5/13
 * Time: 4:00 PM
 */

public class TimeUtil {

    public static int getMinuteOfDay(String time){
        int indexOfDiv = time.indexOf(":");
        String hour = time.substring(0, indexOfDiv);
        String minute = time.substring(indexOfDiv + 1);
        return Integer.parseInt(hour) * 60 + Integer.parseInt(minute);
    }

    public static String getTimeStringOfDay(int minuteOfDay){
        int minute = minuteOfDay%60;
        int hour = minuteOfDay/60;
        String hourStr = (hour < 13)? String.valueOf(hour) : String.valueOf(hour%12);
        String appendStr = (hour < 12)? "AM" : "PM";
        String minuteStr = (minute < 10)? "0" + String.valueOf(minute) : String.valueOf(minute);
        return hourStr + ":" + minuteStr + appendStr ;
    }
}
